local skel = fk.CreateSkill {
  name = "rmt__kewang",
}

skel:addEffect(fk.CardUseFinished, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(skel.name) and target == player then
      if player:getMark("@rmt__kewang-turn") == 0 then
        local useEvent = player.room.logic:getEventsOfScope(GameEvent.UseCard, 1, function(e)
          local use = e.data
          return use.from == player
        end, Player.HistoryTurn)[1]
        return useEvent and useEvent.data == data
      end
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    player.room:setPlayerMark(player, "@rmt__kewang-turn", data.card.number == 0 and "x" or data.card.number)
    player:drawCards(1, skel.name)
  end,
})

skel:addEffect(fk.CardUsing, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(skel.name) and target == player then
      return data.card.number ~= 0 and type(player:getMark("@rmt__kewang-turn")) == "number"
      and player:getMark("@rmt__kewang-turn") ~= 0
      and data.card.number % player:getMark("@rmt__kewang-turn") == 0
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    player:drawCards(1, skel.name)
  end,
})

Fk:loadTranslationTable{
  ["rmt__kewang"] = "可往",
  [":rmt__kewang"] = "你每回合首次使用牌后，摸一张牌，且本回合使用与之倍数牌时，再摸一张牌。",
  ["@rmt__kewang-turn"] = "可往",

  ["$rmt__kewang1"] = "寇可往,吾亦可往。",
  ["$rmt__kewang2"] = "若得阿娇，当以金屋藏之。",
}

return skel
